<?php
namespace ZfcUser\Model;

use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;
use Zend\Db\Sql;
use Zend\Db\Sql\Where;
use Zend\Db\Sql\Select;
use Zend\Paginator\Adapter\DbSelect;
use Zend\Db\Sql\Predicate;
use Zend\Db\Sql\Expression;
use Zend\Paginator\Paginator;
class EmailtokensTable
{
    protected $tableGateway;
	protected $select;
    public function __construct(TableGateway $tableGateway)
    {
        $this->tableGateway = $tableGateway;
		$this->select = new Select();
    }
	public function addToken($id,$token,$update=''){
		if($update===''){
			$data=array(
				 'token'		=>	$token,
				 'email_id'		=>	$id,
				 'status'		=>	1,
				 
			);
			$this->tableGateway->insert($data);
		}else{
			$data=array(
				'status'		=>	0,
			);
			$this->tableGateway->update($data, array('id' => $id));
		}
		return $this->tableGateway->lastInsertValue;
	}
	public function getTokenDetails($token)
	{
		$select = $this->tableGateway->getSql()->select();
		$select->where('id="'.$token.'"');
		$resultSet = $this->tableGateway->selectWith($select);
		return $resultSet;
	}
	public function getToken($token)
	{
		$select = $this->tableGateway->getSql()->select();
		$select->where('token="'.$token.'"');
		$resultSet = $this->tableGateway->selectWith($select);
		return $resultSet;
	}
}